home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3p / pthread_setcancelstate.z / pthread_setcancelstate
Encoding:
Text File  |  2002-10-03  |  10.1 KB  |  133 lines

  1.  
  2.  
  3.  
  4. pppptttthhhhrrrreeeeaaaadddd____sssseeeettttccccaaaannnncccceeeellllssssttttaaaatttteeee((((3333PPPP))))                          pppptttthhhhrrrreeeeaaaadddd____sssseeeettttccccaaaannnncccceeeellllssssttttaaaatttteeee((((3333PPPP))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      pthread_setcancelstate, pthread_setcanceltype, pthread_testcancel -
  10.      manage cancelability of a thread
  11.  
  12. CCCC SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.      ####iiiinnnncccclllluuuuddddeeee <<<<pppptttthhhhrrrreeeeaaaadddd....hhhh>>>>
  14.  
  15.      iiiinnnntttt pppptttthhhhrrrreeeeaaaadddd____sssseeeettttccccaaaannnncccceeeellllssssttttaaaatttteeee((((iiiinnnntttt nnnneeeewwww____ssssttttaaaatttteeee,,,, iiiinnnntttt ****oooolllldddd____ssssttttaaaatttteeee))));;;;
  16.      iiiinnnntttt pppptttthhhhrrrreeeeaaaadddd____sssseeeettttccccaaaannnncccceeeellllttttyyyyppppeeee((((iiiinnnntttt nnnneeeewwww____ttttyyyyppppeeee,,,, iiiinnnntttt ****oooolllldddd____ttttyyyyppppeeee))));;;;
  17.      vvvvooooiiiidddd pppptttthhhhrrrreeeeaaaadddd____tttteeeessssttttccccaaaannnncccceeeellll((((vvvvooooiiiidddd))));;;;
  18.  
  19. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  20.      The cancelability of a thread determines when, if ever, it acts upon
  21.      cancellation requests [see _p_t_h_r_e_a_d__c_a_n_c_e_l(), and _p_t_h_r_e_a_d__e_x_i_t()].
  22.  
  23.      Cancellation state may be either PPPPTTTTHHHHRRRREEEEAAAADDDD____CCCCAAAANNNNCCCCEEEELLLL____EEEENNNNAAAABBBBLLLLEEEE or
  24.      PPPPTTTTHHHHRRRREEEEAAAADDDD____CCCCAAAANNNNCCCCEEEELLLL____DDDDIIIISSSSAAAABBBBLLLLEEEE.  If it is PPPPTTTTHHHHRRRREEEEAAAADDDD____CCCCAAAANNNNCCCCEEEELLLL____DDDDIIIISSSSAAAABBBBLLLLEEEE, then
  25.      cancellation requests are blocked (held pending) indefinitely.  If the
  26.      state is PPPPTTTTHHHHRRRREEEEAAAADDDD____CCCCAAAANNNNCCCCEEEELLLL____EEEENNNNAAAABBBBLLLLEEEE, the cancellation type is the governing
  27.      factor.
  28.  
  29.      Cancellation type may be either PPPPTTTTHHHHRRRREEEEAAAADDDD____CCCCAAAANNNNCCCCEEEELLLL____AAAASSSSYYYYNNNNCCCCHHHHRRRROOOONNNNOOOOUUUUSSSS or
  30.      PPPPTTTTHHHHRRRREEEEAAAADDDD____CCCCAAAANNNNCCCCEEEELLLL____DDDDEEEEFFFFEEEERRRRRRRREEEEDDDD.  The type only affects the cancelability of a
  31.      thread if the cancellation state is PPPPTTTTHHHHRRRREEEEAAAADDDD____CCCCAAAANNNNCCCCEEEELLLL____EEEENNNNAAAABBBBLLLLEEEE.
  32.  
  33.      If the type is PPPPTTTTHHHHRRRREEEEAAAADDDD____CCCCAAAANNNNCCCCEEEELLLL____DDDDEEEEFFFFEEEERRRRRRRREEEEDDDD, cancellation requests are only
  34.      acted on when the thread is in a known state, namely that it enters or is
  35.      waiting in a set of functions known as cancellation points (see NNNNOOOOTTTTEEEESSSS).
  36.      Usually these are functions in which a thread may block for an unbounded
  37.      period of time.  If the cancellation request is acted upon at a
  38.      cancellation point, the operation associated with the function is
  39.      aborted.  For example, if a _r_e_a_d() is in progress when the thread is
  40.      cancelled, then either the _r_e_a_d() will return data or the cancellation
  41.      will be acted upon.  Should the thread read data before the request
  42.      arrives, it will not be cancelled.
  43.  
  44.      If the type is PPPPTTTTHHHHRRRREEEEAAAADDDD____CCCCAAAANNNNCCCCEEEELLLL____AAAASSSSYYYYNNNNCCCCHHHHRRRROOOONNNNOOOOUUUUSSSS, then cancellation requests
  45.      may take effect immediately.  This type of cancellation should only be
  46.      used when the state of target thread is known.  If the target thread is
  47.      executing exclusively in user code (for example in a computation loop)
  48.      this is safe.  However, this is not the case if the thread makes calls to
  49.      a library.  For this reason deferred cancellation should be preferred to
  50.      asynchronous cancellation.
  51.  
  52.      Cancellation handlers [see _p_t_h_r_e_a_d__c_l_e_a_n_u_p__p_u_s_h()] can be used to restore
  53.      application state when a thread is cancelled.
  54.  
  55.      When threads start, their cancellation state is PPPPTTTTHHHHRRRREEEEAAAADDDD____CCCCAAAANNNNCCCCEEEELLLL____EEEENNNNAAAABBBBLLLLEEEE and
  56.      their cancellation type is PPPPTTTTHHHHRRRREEEEAAAADDDD____CCCCAAAANNNNCCCCEEEELLLL____DDDDEEEEFFFFEEEERRRRRRRREEEEDDDD.
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. pppptttthhhhrrrreeeeaaaadddd____sssseeeettttccccaaaannnncccceeeellllssssttttaaaatttteeee((((3333PPPP))))                          pppptttthhhhrrrreeeeaaaadddd____sssseeeettttccccaaaannnncccceeeellllssssttttaaaatttteeee((((3333PPPP))))
  71.  
  72.  
  73.  
  74.      The _p_t_h_r_e_a_d__s_e_t_c_a_n_c_e_l_s_t_a_t_e() function changes the calling thread's
  75.      cancellation state to _n_e_w__s_t_a_t_e which can be either
  76.      PPPPTTTTHHHHRRRREEEEAAAADDDD____CCCCAAAANNNNCCCCEEEELLLL____DDDDIIIISSSSAAAABBBBLLLLEEEE or PPPPTTTTHHHHRRRREEEEAAAADDDD____CCCCAAAANNNNCCCCEEEELLLL____EEEENNNNAAAABBBBLLLLEEEE.  If _o_l_d__s_t_a_t_e is not
  77.      NNNNUUUULLLLLLLL, then it is used to return the previous state.  If the state is
  78.      changed to PPPPTTTTHHHHRRRREEEEAAAADDDD____CCCCAAAANNNNCCCCEEEELLLL____EEEENNNNAAAABBBBLLLLEEEE and there is a cancellation request
  79.      pending, then it will be acted on immediately.
  80.  
  81.      The _p_t_h_r_e_a_d__s_e_t_c_a_n_c_e_l_t_y_p_e() function changes the calling thread's
  82.      cancellation type to _n_e_w__t_y_p_e which can be either
  83.      PPPPTTTTHHHHRRRREEEEAAAADDDD____CCCCAAAANNNNCCCCEEEELLLL____AAAASSSSYYYYNNNNCCCCHHHHRRRROOOONNNNOOOOUUUUSSSS or PPPPTTTTHHHHRRRREEEEAAAADDDD____CCCCAAAANNNNCCCCEEEELLLL____DDDDEEEEFFFFEEEERRRRRRRREEEEDDDD.  If _o_l_d__t_y_p_e is
  84.      not NNNNUUUULLLLLLLL, then it is used to return the previous type.
  85.  
  86.      The _p_t_h_r_e_a_d__t_e_s_t_c_a_n_c_e_l() function is a cancellation point.  If
  87.      cancellation is enabled and a cancellation request is pending on the
  88.      thread, then calling this function will terminate the thread.
  89.  
  90. DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  91.      The functions _p_t_h_r_e_a_d__s_e_t_c_a_n_c_e_l_s_t_a_t_e() and _p_t_h_r_e_a_d__s_e_t_c_a_n_c_e_l_t_y_p_e() return
  92.      zero.
  93.  
  94. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  95.      pthread_cancel(3P), pthread_exit(3P), pthread_cleanup_push(3P).
  96.  
  97. NNNNOOOOTTTTEEEESSSS
  98.      The following functions are cancellation points:
  99.  
  100.        _a_c_c_e_p_t(_2)               _a_i_o__s_u_s_p_e_n_d(_3)     _c_l_o_s_e(_2)
  101.        _c_o_n_n_e_c_t(_2)              _c_r_e_a_t(_2)           _f_c_n_t_l(_2)
  102.        _f_s_y_n_c(_2)                _g_e_t_m_s_g(_2)          _g_e_t_p_m_s_g(_2)
  103.        _l_o_c_k_f(_3_C)               _m_q__r_e_c_e_i_v_e         _m_q__s_e_n_d
  104.        _m_s_g_r_c_v(_2)               _m_s_g_s_n_d(_2)          _m_s_y_n_c(_2)
  105.        _n_a_n_o_s_l_e_e_p(_2)            _o_p_e_n(_2)            _p_a_u_s_e(_2)
  106.        _p_o_l_l(_2)                 _p_r_e_a_d(_2)           _p_t_h_r_e_a_d__c_o_n_d__t_i_m_e_d_w_a_i_t(_3_P)
  107.        _p_t_h_r_e_a_d__c_o_n_d__w_a_i_t(_3_P)   _p_t_h_r_e_a_d__j_o_i_n(_3_P)   _p_t_h_r_e_a_d__t_e_s_t_c_a_n_c_e_l(_3_P)
  108.        _p_u_t_m_s_g(_2)               _p_u_t_p_m_s_g(_2)         _p_w_r_i_t_e(_2)
  109.        _r_e_a_d(_2)                 _r_e_a_d_v(_2)           _r_e_c_v(_2)
  110.        _r_e_c_v_f_r_o_m(_2)             _r_e_c_v_m_s_g(_2)         _s_e_l_e_c_t(_2)
  111.        _s_e_m__w_a_i_t                _s_e_m_o_p(_2)           _s_e_n_d(_2)
  112.        _s_e_n_d_m_s_g_s_e_n_d_t_o(_2)        _s_i_g_p_a_u_s_e(_2)        _s_i_g_s_u_s_p_e_n_d(_2)
  113.        _s_i_g_t_i_m_e_d_w_a_i_t(_3)         _s_i_g_w_a_i_t(_3)         _s_i_g_w_a_i_t_i_n_f_o(_3)
  114.        _s_l_e_e_p(_3_C)               _s_y_s_t_e_m(_3_S)         _t_c_d_r_a_i_n(_3_t)
  115.        _u_s_l_e_e_p(_3_C)              _w_a_i_t(_2)            _w_a_i_t_3(_2)
  116.        _w_a_i_t_i_d(_2)               _w_a_i_t_p_i_d(_2)         _w_r_i_t_e(_2)
  117.        _w_r_i_t_e_v(_2)
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.